package com.example.myapplication;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {
    private EditText editText1;
    private Button button1;
    private TextView textView1;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        textView1=(TextView) findViewById(R.id.tv_1);
        button1=(Button)findViewById(R.id.btn_1);
        editText1=(EditText)findViewById(R.id.et_1);
        //取出从页面2发送过来的数据并显示在文本框中
        Intent intent1_2=getIntent();
        String str1=intent1_2.getStringExtra("cc");
        textView1.setText(str1);
        button1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //创建意图
                Intent intent1_1=new Intent(MainActivity.this,Main2Activity.class);
                //带数据：把数据存到意图中
                intent1_1.putExtra("aa",editText1.getText().toString().trim());
                //启动活动
                startActivity(intent1_1);
            }
        });
    }
}
